// custom-tab-bar/index.js
const app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    acitvedIndex: 0,
    list: [{
        pagePath: "/pages/index/index",
        icon: "home",
        text: "首页",
      },
      {
        pagePath: "/pages/message/message",
        text: "消息",
        icon: 'chat'
      },
      {
        pagePath: "/pages/scan/scan",
        text: "扫一扫",
        bulge: true,
        icon: 'scan',
      },
      {
        pagePath: "/pages/serviceDesk/serviceDesk",
        text: "工作台",
        icon: 'app',
      },
      {
        pagePath: "/pages/my/my",
        text: "我的",
        icon: 'user',
      }
    ]
  },

  lifetimes: {
    ready() {


    },
    attached: function () {
      this.setData({
        acitvedIndex: app.globalData.acitvedIndex
      })
      // 在组件实例进入页面节点树时执行
    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab({
      currentTarget
    }) {
      if (currentTarget.dataset.index != 2) {
        app.globalData.acitvedIndex = currentTarget.dataset.index
        wx.switchTab({
          url: currentTarget.dataset.path,
        })
      }

    }
  }
})